package com.zzyk.microCloud.api.controller;

import com.zzyk.main.model.vo.Message;
import com.zzyk.main.service.DeviceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wss_PC
 * @DESCRIPTION 设备类型
 * @create 2020/10/26 14:26
 */
@RequestMapping("api/deviceType")
@RestController
public class ApiDeviceTypeController {
    @Autowired
    private DeviceTypeService deviceTypeService;


    /**
     * 根据排行查询设备类型
     * @param rank
     * @return
     */
    @GetMapping("/selectAllByRank")
    public Message selectAllByRank(Integer rank){
        return Message.success().addData("data",deviceTypeService.selectByRank(rank));
    }

    /**
     * 根据父级ID查询设备类型
     * @param parentId
     * @return
     */
    @GetMapping("/selectAllByParentId")
    public Message selectAllByParentId(@RequestParam(value = "parentId", defaultValue = "0") Integer parentId){
        return Message.success().addData("data",deviceTypeService.selectByParentId(parentId));
    }

    /**
     * 查询所有设备类型数据
     * @return
     */
    @GetMapping("/selectDeviceTypeTree")
    public Message selectAllDeviceType(){
        return Message.success().addData("data",deviceTypeService.selectDeviceTypeTree());
    }

}